// 建议用函数组件
// 新知识点：路由懒加载
// 需要涉及到的模块或者组件
// Suspense组件，由react包提供，其实一个组件
//    语法：<Suspense falback = {加载提示内容}>路由规则</>
// lazy方法：react提供，用于动态加载需要渲染的组件
//    语法：const 组件用用变量名 = lazy(() => import(“组件的路径”))

import React, { lazy, Suspense } from 'react';
import { Switch, Redirect, Route } from 'react-router-dom';

import Loading from "../components/Loading"
const Login = lazy(() => import("../views/login/index"))
const Dashboard = lazy(() => import("../views/backend/Dashboard"))
const Index = () => {
  return (
    <Suspense fallback={<Loading />}>
      <Switch>
        <Redirect exact from="/" to="/login" />
        <Route path="/login" component={Login} />
        <Route path="/dashboard" component={Dashboard} />
      </Switch>
    </Suspense>
  )
}
export default Index;
